<?php
namespace App\Admin\Grid\Displayers;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\Displayers\Editable;

class EditableWithAuth extends Editable
{
    protected $type = 'input';

    protected $view = 'admin::grid.displayer.editinline.input';

    public function display($options = [])
    {
        $is_enable  = true;
        if (isset($options['is_enable'])) {
            $is_enable = boolval($options['is_enable']);
        }
        if (!$is_enable) {
            # 不允许的情况返回原值
            return $this->column->getOriginal();
        }

        if (! empty($options['mask'])) {
            Admin::requireAssets('@jquery.inputmask');
        }

        return parent::display($options);
    }
}
